package com.igeek.web;

import com.alibaba.fastjson.JSONArray;
import com.igeek.domain.Category;
import com.igeek.service.CategoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/category")
public class CategoryServlet extends BaseServlet {


    public void findAllCategory(HttpServletRequest request,HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        CategoryService categoryService=new CategoryService();
        List<Category> categoryList=categoryService.getAllCategory();
        String json= JSONArray.toJSONString(categoryList);
        response.getWriter().write(json);
    }
}
